<a href="<?=base_url("no_edit/no_edit_photo/add_photo_frame")?>" class="layui-btn layui-btn-lg layui-btn-normal" style="float: right;">新增</a>
<br><br><br>
<table class="layui-table">
    <colgroup>
        <col width="8%">
        <col width="8%">
        <col width="8%">
        <col width="20%">
        <col width="5%">
        <col width="12%">
        <col width="15%">
    </colgroup>
    <thead>
    <tr>
        <th>效果图</th>
        <th>模板上图</th>
        <th>模板下图</th>
        <th>名称</th>
        <th>状态</th>
        <th>添加时间</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <?php if(!empty($data['row'])){
        foreach($data['row'] as $k=>$v){
            ?>
            <tr>
                <input type="hidden" value="<?=$v['id']?>" class="id<?=$k+1?>">
                <td>
                    <img src="<?=$v['xiaoguo_url']?>" style="width:80px;height:70px;" class="tom_show_image">
                </td>
                <td>
                    <img src="<?=$v['moban_up_url']?>" style="width:80px;height:70px;" class="tom_show_image">
                </td>
                <td>
                    <img src="<?=$v['moban_down_url']?>" style="width:80px;height:70px;" class="tom_show_image">
                </td>
                <td><?=$v['photo_frame_title']?></td>
                <?php if($v['photo_online']==1){ ?>
                    <td>下线</td>
                <?php }else if($v['photo_online']==2){ ?>
                    <td>上线</td>
                <?php } ?>
                <td><?=$v['add_time']?></td>

                <td>
                    <a href="<?=base_url("no_edit/no_edit_photo/edit_add_photo_frame?id={$v['id']}")?>" class="layui-btn layui-btn-xs" style="margin-left:5px;margin-bottom:8px;">编辑</a>
                    <?php if($v['photo_online']==2){ ?>
                        <button class="layui-btn layui-btn-xs layui-btn-warm photo_frame_stop<?=$k+1?>" style="margin-left:5px;margin-bottom:8px;">停用</button>
                    <?php }else if($v['photo_online']==1){ ?>
                        <button class="layui-btn layui-btn-xs layui-btn-normal photo_frame_up<?=$k+1?>" style="margin-left:5px;margin-bottom:8px;">启用</button>
                    <?php } ?>
                    <button class="layui-btn layui-btn-xs layui-btn-danger photo_frame_del<?=$k+1?>" style="margin-left:5px;margin-bottom:8px;">删除</button>
                </td>
            </tr>
        <?php }}else{ ?>
        <tr>
            <td colspan="6" rowspan="3" style="color: #00CC00;font-size: 25px;height:100px;text-align: center;">暂无数据</td>
        </tr>
    <?php } ?>
    </tbody>
</table>
<div id="demo7"></div>
<script src="<?=SITE_BASE_URL?>/assets/plugins/dyj/layui_url.js"></script>

<script>
    $(function(){
        //定义一个51的jquery数组
        var arr=[];
        for(var i=1;i<51;i++){
            arr.push(i)
        }
        $.each(arr,function(i,n){
            var id=$(".id"+n).val();
            //停用
            $(".photo_frame_stop"+n).click(function(){
                $.ajax({
                    type:"post",
                    data:{id:id},
                    dataType: "json",
                    url:"<?=base_url("no_edit/no_edit_photo/photo_frame_stop")?>",
                    success:function(res){
                        if(res.code==0){
                            layer.msg(res.msg, {time: 2000},function(){
                                window.location.reload();
                            });
                        }else{
                            layer.msg(res.msg, {time: 2000});
                        }
                    }
                })
            })

            //启用
            $(".photo_frame_up"+n).click(function(){
                $.ajax({
                    type:"post",
                    data:{id:id},
                    dataType: "json",
                    url:"<?=base_url("no_edit/no_edit_photo/photo_frame_up")?>",
                    success:function(res){
                        if(res.code==0){
                            layer.msg(res.msg, {time: 2000},function(){
                                window.location.reload();
                            });
                        }else{
                            layer.msg(res.msg, {time: 2000});
                        }
                    }
                })
            })

            //移除
            $(".photo_frame_del"+n).click(function(){
                $.ajax({
                    type:"post",
                    data:{id:id},
                    dataType: "json",
                    url:"<?=base_url("no_edit/no_edit_photo/photo_frame_del")?>",
                    success:function(res){
                        if(res.code==0){
                            layer.msg(res.msg, {time: 2000},function(){
                                window.location.reload();
                            });
                        }else{
                            layer.msg(res.msg, {time: 2000});
                        }
                    }
                })
            })
        })

        //分页
        layui.use('laypage', function(){
            var laypage = layui.laypage;
            var param = GetRequest();
            //总页数大于页码总数
            laypage.render({
                elem: 'demo7'
                ,count:<?=$data['total']?>//数据总数
                ,curr: <?=$page?>
                ,limit:<?=$limit?>
                ,layout:  ['count', 'prev', 'page', 'next','limit', 'refresh', 'skip']
                ,jump: function(obj,first){
                    //首次不执行
                    if(!first){
                        var url = window.location.href;
                        url = url.substring(0, url.lastIndexOf('?'));

                        param['page'] = obj.curr;
                        param['limit'] = obj.limit;
                        window.location.href = createURL(url,param);
                    }
                }
            });
        });
    })
</script>